package ph.com.gs3.formalistics.model.vo.parsers.json;

import org.json.JSONException;
import org.json.JSONObject;

import ph.com.gs3.formalistics.model.vo.business.Comment;
import ph.com.gs3.formalistics.model.vo.business.User;

public class CommentJSONParser {

	public static Comment createFromJSON(JSONObject raw) throws JSONException {

		Comment comment = new Comment();

		comment.setWebId(raw.getString("id"));		
		
		comment.setText(raw.getString("text"));
		comment.setDateCreated(raw.getString("date_created"));		
		
		return comment;

	}
	
	public static String getCommentDocumentWebIdFromJSON(JSONObject raw) throws JSONException {
		return raw.getString("request_id");
	}

	public static User createCommentAuthorFromJSON(JSONObject raw) throws JSONException {

		User user = new User();

		user.setWebId(raw.getString("author_id"));
		user.setDisplayName(raw.getString("author_display_name"));
		user.setImageURL(raw.getString("author_image_url"));

		return user;

	}

}
